Previous Book Contents Book Index Next

Inside Macintosh: /
QuickDraw 3D RAVE / QuickDraw 3D RAVE Reference
Constants


Blending Operations

A drawing engine may support a transparency blending function that determines the kind of transparency blending applied to a drawing context when combining new ("source") pixels with the pixels already in a frame buffer ("destination"). You specify an engine's transparency blending function by assigning a value to its kQATag_Blend state variable. The default value of this variable for a draw context that supports transparency blending is kQABlend_PreMultiply.

In the equations below, the factors as, rs, gs, and bs represent the alpha, red, green and blue components of a source pixel; the factors ad, rd, gd, and bd represent the alpha, red, green and blue components of a destination pixel.

#define kQABlend_PreMultiply           0
#define kQABlend_Interpolate           1
#define kQABlend_OpenGL                2
Constant descriptions

kQABlend_PreMultiply
The drawing engine uses a premultiplied blending function. The components of a pixel written to the frame buffer are computed using these equations: a = 1+-((1+-INDEXES (not implemented))×(1+-INDEXES (not implemented))) r = INDEXES (not implemented)+((1+-INDEXES (not implemented))×INDEXES (not implemented)) g = INDEXES (not implemented)+((1+-INDEXES (not implemented))×INDEXES (not implemented)) b = INDEXES (not implemented)+((1+-INDEXES (not implemented))×INDEXES (not implemented))
In general, you should use the premultiplied blending function for rendering shaded transparent 3D primitives (such as triangles). The premultiplied function does not scale the source color components by the alpha value as; as a result, this function allows a transparent object to have a specular highlight value that is greater than its alpha channel value. For example, a sheet of glass might allow 99% of the light behind it to pass though (indicating an alpha channel value of 0.01). However, that same sheet of glass might have a specular highlight value much greater than 0.01. The premultiplied function allows the drawing engine to render this object correctly.
kQABlend_Interpolate
The drawing engine uses an interpolated blending function. The components of a pixel written to the frame buffer are computed using these equations: a = 1+-((1+-INDEXES (not implemented))×(1+-INDEXES (not implemented))) r = (INDEXES (not implemented)×INDEXES (not implemented))+((1+-INDEXES (not implemented))×INDEXES (not implemented)) g = (INDEXES (not implemented)×INDEXES (not implemented))+((1+-INDEXES (not implemented))×INDEXES (not implemented)) b = (INDEXES (not implemented)×INDEXES (not implemented))+((1+-INDEXES (not implemented))×INDEXES (not implemented))
The interpolated blending function is not entirely suitable for rendering shaded transparent objects, but it is very effective for compositing bitmap images.
kQABlend_OpenGL
The drawing engine uses the OpenGL blending function determined by the values of the kQATagGL_BlendSrc and kQATagGL_BlendDest state variables. For complete information on OpenGL blending functions, consult the description of the glBlendFunc function in OpenGL(TM) Reference Manual. OpenGL blending functions are supported only by drawing engines that support the kQAOptional_OpenGL feature.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
28 AUG 1996